package com.open.capacity;


import com.open.capacity.finance.config.Globals;
import com.open.capacity.reptile.service.*;
import com.open.capacity.user.service.SysCompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class StartEventListener implements ApplicationListener<ApplicationStartedEvent> {

    @Autowired
    private SysCompanyService companyService;

    @Autowired
    private GdszczMaEleExpecoService maEleExpecoService;
    @Autowired
    private GdszczMaEleExpFuncService maEleExpFuncService;
    @Autowired
    private GdszczMaEleProjectService maEleProjectService;
    @Autowired
    private GdszczMaEleDepproService maEleDepproService;

    @Autowired
    private GdszczMaEleAccoService maEleAccoService;


    @Override
    public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {

        Globals.companyList = companyService.findAll(new HashMap<>());

        Map<String, Object> param = new HashMap<>();
        Globals.kjkmList = maEleAccoService.findAll(param);
        param.put("isLeaf", 1);
        Globals.expecoList = maEleExpecoService.findAll(param);
        Globals.expfuncList = maEleExpFuncService.findAll(param);
        Globals.projectList = maEleProjectService.findAll(param);
        Globals.depproList = maEleDepproService.findAll(param);
    }
}
